<template>
  <div class="box">
    <div class="swiper">
      <van-swipe :autoplay="3000" style="width: 100%; height: 200px">
        <van-swipe-item v-for="(image, index) in images" :key="index">
          <router-link  :to="{ path: '/detail', query: { articleId: image.articleId } }">
          <img :src="image.coverImgUrl" />
          <p>{{ image.title }}</p></router-link>
        </van-swipe-item>
      </van-swipe>
    </div>
  </div>
</template>

<script>
import { getSwiper } from "../api/api";

export default {
  data() {
    return {
      images: [],
    };
  },
  created() {
    getSwiper().then((res) => {
      // console.log(res);
      this.images = res.rows;
    });
  },
};
</script>

<style lang="less" scoped>
.swiper {
  width: 100%;
  height: 200px;
  position: relative;
  img {
    width: 100%;
    height: 100%;
  }
}
p {
  position: absolute;
  bottom: 20px;
  left: 65px;
  font-size: 12px;
  text-decoration-color: #fff;
}
</style>